package com.jtech.together.manager;

import android.content.Context;
import android.text.TextUtils;

import com.jtech.together.common.Constants;
import com.jtech.together.manager.base.BaseCacheManager;

/**
 * 设置参数管理
 * Created by wuxubaiyang on 2017/5/10.
 */

public class SettingManager extends BaseCacheManager {
    private static final String KEY_ADD_FRIEND = "keyAddFriend";

    private static SettingManager INSTANCE;

    public SettingManager(Context context) {
        super(context);
    }

    /**
     * 获取单利
     *
     * @param context
     * @return
     */
    public static SettingManager get(Context context) {
        if (null == INSTANCE) {
            INSTANCE = new SettingManager(context);
        }
        return INSTANCE;
    }

    /**
     * 判断是否已发送过添加好友的请求
     *
     * @param objectId
     * @return
     */
    public boolean isSendAddFriendMessage(String objectId) {
        return !TextUtils.isEmpty(getString(KEY_ADD_FRIEND + objectId));
    }

    /**
     * 标记已经发送过添加好友的请求
     * 时间为1天，一天内不能重复发送请求
     *
     * @param objectId
     * @return
     */
    public void flagSendAddFriendMessage(String objectId) {
        put(KEY_ADD_FRIEND + objectId, objectId, 1000 * 60 * 60 * 24);
    }

    @Override
    public String getCacheName() {
        return Constants.CACHE_NAME;
    }
}